function ajax(method, url, data) {
    var xhr = null;
    if (XMLHttpRequest) {
        xhr = new XMLHttpRequest()
    } else {
        xhr = new ActiveXObject("Microsoft.XMLHTTP")
    }
    if (method == "get") {
        // console.log(1);
        xhr.open(method, url + "?" + data, true);
        xhr.send();
    } else {
        // console.log(2);
        xhr.open(method, url, true);
        xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
        xhr.send(data);
    }
    return new Promise((sucee, fail)=> {
        xhr.onreadystatechange = ()=> {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    sucee(xhr.responseText)
                } else {
                    fail(xhr.status)
                }
            }
        }
    })

}
